from ironxl import *
# Load existing spreadsheet
workbook = WorkBook.Load("sample.xls")
worksheet = workbook.WorkSheets[0]
# Get range from the worksheet
selected_range = worksheet["A1:A8"]
# Apply sum of all numeric cells within the range
sum_ = selected_range.Sum()
# Apply average value of all numeric cells within the range
avg = selected_range.Avg()
# Identify maximum value of all numeric cells within the range
max_ = selected_range.Max()
# Identify minimum value of all numeric cells within the range
min_ = selected_range.Min()
Excel 聚合函数
上面的代码示例展示了如何使用IronXL for Python从Excel电子表格中检索单元格范围的聚合值。 请注意,所选范围内的任何非数字单元格将被排除在计算之外。